//
//  CYPayBackDetailTableVC.m
//  CreditAddressBook
//
//  Created by LE on 15/11/3.
//  Copyright © 2015年 Lee. All rights reserved.
//

#import "CYPayBackDetailTableVC.h"
#import "CYMeHttpTool.h"
#import "CYCreditTool.h"
#import "CYEscape.h"

@interface CYPayBackDetailTableVC ()

@property(nonatomic, strong) NSArray *data;
@end

@implementation CYPayBackDetailTableVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor redColor];
    self.title = @"还款详情";
    
    [self loadData];
}

- (void)loadData {
    [CYMeHttpTool payBackDetailListWithParams:@{@"payBackRecordId": [CYEscape escapeWithString:self.dic[@"payBackRecordId"]], @"token": @"a", @"userId": @"1"} success:^(NSArray *arr) {
        self.data = arr;
        [self.tableView reloadData];
    } failure:^(NSError *error) {
        
    }];
}

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.data.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *ID = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:ID];
    }
    
    NSDictionary *a = self.data[indexPath.row];
    NSString *date = [NSString stringWithFormat:@"%@", a[@"insertTime"][@"time"]];
    NSString *time = [CYCreditTool timewithLongLongValue:date.longLongValue formatter:nil];
    cell.textLabel.text = time;
    cell.detailTextLabel.text = [NSString stringWithFormat:@"%@", a[@"payBackMoney"]];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
}

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
